<!DOCTYPE HTML>
<style type="text/css">
[class^="icon-"], [class*=" icon-"] {
    display: inline-block;
    width: 14px;
    height: 14px;
    line-height: 14px;
    vertical-align: text-top;
    background-image: url("__PUBLIC__/images/glyphicons-halflings.png");
    background-position: 14px 14px;
    background-repeat: no-repeat;
    margin-top: 1px;
}
.input-append .add-on,.input-prepend .add-on{display:inline-block;width:auto;height:20px;min-width:16px;padding:4px 5px;font-size:14px;font-weight:normal;line-height:20px;text-align:center;text-shadow:0 1px 0 #ffffff;background-color:#eeeeee;border:1px solid #ccc;}
.input-append .add-on,.input-prepend .add-on,.input-append .btn,.input-prepend .btn,.input-append .btn-group>.dropdown-toggle,.input-prepend .btn-group>.dropdown-toggle{vertical-align:top;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;}
.input-append .add-on, .input-append .btn, .input-append .btn-group {
    margin-left: -1px;
	-webkit-box-sizing: content-box;
}
.form_datetime{
    font-size: 0;
}
.form_datetime input[type="text"]{
       
}
.icon-remove {
    background-position: -312px 0;
	    white-space: nowrap;
		-webkit-box-sizing: content-box;
}
.icon-th {
    background-position: -240px 0;
	    white-space: nowrap;
		-webkit-box-sizing: content-box;
}
input[type="text"]{
	z-index: 9999; 
    border-left-width: 1px;
    border-right-width: 1px;
	vertical-align: top;
		    padding: 6px 3px;
}
input[type="text"]:focus{
	z-index: 9999; 
    border-left-width: 1px;
    border-right-width: 1px;
	vertical-align: top;
	position: relative;	
	padding: 6px 3px;
}
.my-span-th{
    left: 100px;
	width:0px !important;
    /*height: 0px !important;*/
    min-width: 0px !important;
    padding: 4px 0px !important;
    position: relative;
    z-index: -1;
}
.container{
	width:1250px;
	margin-left:0px;
	margin-right:15px;
	padding-left:0px;
}
.form-body {
    padding: 0.5em 0.5em;
}
.a-upload {
	background-color: rgba(97, 100, 193, 0.85);
    color: #fff;
    padding: .5em 1.5em;
    border: none;
    outline: none;
    border-radius: inherit;
   
    display: inline-block;
  
    margin-bottom: 0;
    font-size: 14px;
    font-weight: normal;
    line-height: 1.42857143;
    text-align: center;
        white-space: nowrap;
    vertical-align: middle;
    touch-action: manipulation;
    cursor: pointer;
    -webkit-user-select: none;
    height: 34px;
    position: relative;

    <!-- -webkit-appearance: button; -->
	text-transform: none;
	    box-sizing: border-box;
align-items: flex-start;
   

    overflow: hidden;
    *display: inline;
    *zoom: 1
}

.a-upload  input {
    position: absolute;
    font-size: 100px;
    right: 0;
    top: 0;
    opacity: 0;
    filter: alpha(opacity=0);
    cursor: pointer
}

.a-upload:hover {
    color: #444;
    background: #eee;
    border-color: #ccc;
    text-decoration: none
}
</style>
<div class="container">
<div class="forms">
<!-- <div class="inline-form widget-shadow"> -->
<div class="bs-example widget-shadow" data-example-id="contextual-table">
						<div class="form-title">
							<h4>时间控制</h4>
						</div>
						<div class="form-body">
						
		<table class="table"> 
			<thead> 
				<tr> 
					<!-- <th>#</th>  -->
					<th>作业</th> 
					<th>提交开始</th> 
					<th>提交结束</th> 
					
					<th>补交结束</th> 
					<th>互评开始</th> 
					<th>互评结束</th> 
					<th>操作</th> 
				</tr> 
			</thead> 
			<tbody>
					
					<volist name="list" id="vo">
						<!-- <th scope="row" >{$i}</th>  -->
						<td>{$vo.ex_name}</td> 
						<td>
							<div class="control-group">               
								<div class="controls input-append date form_datetime" data-date="" data-date-format="dd MM yyyy - HH:ii p" data-link-field="dtp_input_{$vo.id}_1" id="{$vo.id}_1">							
									<span class="add-on my-span-th"><i class="icon-th"></i></span>	   
									<input size="16" type="text" value="{$vo.updatastart}" readonly class="form-control" placeholder="选择时间" style="display:inline-block;width:135px;;-webkit-box-sizing: content-box;    height: 16px;z-index: 9999;  ">
									<span class="add-on"><i class="icon-remove"></i></span>
									             				
								</div>
								<input type="hidden" id="dtp_input_{$vo.id}_1" value="" />
							</div>								
						</td> 
						<td>
							<div class="control-group">               
								<div class="controls input-append date form_datetime" data-date="" data-date-format="dd MM yyyy - HH:ii p" data-link-field="dtp_input{$vo.id}_2" id="{$vo.id}_2">							
										<span class="my-span-th add-on "><i class="icon-th"></i></span>	   
									<input size="16" type="text" value="{$vo.updataend}" readonly class="form-control" placeholder="选择时间" style="display:inline-block;width: 135px;;-webkit-box-sizing: content-box;    height: 16px;z-index: 9999;  ">
									<span class="add-on"><i class="icon-remove"></i></span>
								             				
								</div>
								<input type="hidden" id="dtp_input{$vo.id}_2" value="" />
							</div>
						
						
						</td> 
						
						<td>
							<div class="control-group">               
								<div class="controls input-append date form_datetime" data-date="" data-date-format="dd MM yyyy - HH:ii p" data-link-field="dtp_input{$vo.id}_3" id="{$vo.id}_3">							
									<span class="add-on my-span-th"><i class="icon-th"></i></span>	
									<input size="16" type="text" value="{$vo.resubmitend}" readonly class="form-control" placeholder="选择时间" style="display:inline-block;width: 135px;;-webkit-box-sizing: content-box;    height: 16px;z-index: 9999;  ">
									<span class="add-on"><i class="icon-remove"></i></span>
									                				
								</div>
								<input type="hidden" id="dtp_input{$vo.id}_3" value="" />
							</div>	
						</td>
						<td>
							<div class="control-group">               
								<div class="controls input-append date form_datetime" data-date="" data-date-format="dd MM yyyy - HH:ii p" data-link-field="dtp_input{$vo.id}_4" id="{$vo.id}_4">							
									<span class="add-on my-span-th"><i class="icon-th"></i></span>	
									<input size="16" type="text" value="{$vo.responsestart}" readonly class="form-control" placeholder="选择时间" style="display:inline-block;width: 135px;;-webkit-box-sizing: content-box;    height: 16px;z-index: 9999;  ">
									<span class="add-on"><i class="icon-remove"></i></span>
									                				
								</div>
								<input type="hidden" id="dtp_input{$vo.id}_4" value="" />
							</div>	
						</td>
						<td>
							<div class="control-group">               
								<div class="controls input-append date form_datetime" data-date="" data-date-format="dd MM yyyy - HH:ii p" data-link-field="dtp_input{$vo.id}_5" id="{$vo.id}_5">							
									<span class="add-on my-span-th"><i class="icon-th"></i></span>	
									<input size="16" type="text" value="{$vo.responseend}" readonly class="form-control" placeholder="选择时间" style="display:inline-block;width: 135px;;-webkit-box-sizing: content-box;    height: 16px;z-index: 9999;  ">
									<span class="add-on"><i class="icon-remove"></i></span>
									                				
								</div>
								<input type="hidden" id="dtp_input{$vo.id}_5" value="" />
							</div>	
						</td>
						<td><a href="">
								删除
							</a>
						</td>					
					</tr> 
				</volist>				
			</tbody> 
		</table> 
						
						
			<div data-example-id="simple-form-inline" style="border-top-width: thin;border-color: #ccc;border-top-style: double;padding-top: 10px;"> 
			<form class="form-inline"> 
			<div class="form-group"> 
			<input type="email" class="form-control" id="exampleInputEmail3" placeholder="作业名称"   > 
			</div> 
			<div class="form-group" style="margin-left:10px">
			<a href="javascript:;" class="a-upload">
				<input type="file" name="" id=""><div class="showFileName">上传作业试卷</div>
			</a> 
			<!-- <p class="help-block">Example block-level help text here.</p>  -->
			</div> 
			
			<!-- <div class="checkbox"> 
			<label> <input type="checkbox"> Remember me </label> 
			</div>  -->
			<button type="submit" class="btn btn-default">添加</button> 
			</form> 
			</div>
						</div>
					</div>
</div>


</div>   





<!-- <script type="text/javascript" src="__PUBLIC__/js/jquery-1.8.3.min.js" charset="UTF-8"></script> -->
<script type="text/javascript" src="__PUBLIC__/js/bootstrap.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
<script type="text/javascript" src="__PUBLIC__/js/bootstrap-datetimepicker.fr.js" charset="UTF-8"></script>
<script type="text/javascript">
	function checkTime(event,object){
		var prevDate = $(object).parents('td').prev('td').children().children(".form_datetime").children("input[type='text']").val();
		//prevDate = $(prevDate).children("span");
		//console.log(object);
		
		var nowDate =  $(object).children("input[type='text']").val();
		if(prevDate&&nowDate<prevDate) {
			alert("时间设置错误！");
			return false;
		}else return true;
		
			

	}	
	$(".a-upload").on("change","input[type='file']",function(){
		var filePath=$(this).val();
		if(filePath.indexOf("doc")!=-1 || filePath.indexOf("docx")!=-1){
			$(".fileerrorTip").html("").hide();
			var arr=filePath.split('\\');
			var fileName=arr[arr.length-1];
			$(".showFileName").html(fileName);
		}else{
			//$(".showFileName").html("");
			alert("您未上传文件，或者您上传文件类型有误！请上传word格式文件");
			return false ;
		}
	});
	
    $('.form_datetime').datetimepicker({
        //language:  'fr',
		format:'yyyy-mm-dd hh:ii:ss',
		language:  'en',
        weekStart: 1,
        todayBtn:  1,
		autoclose: 1,
		todayHighlight: 1,
		startView: 2,
		forceParse: 0,
        showMeridian: 1,
		pickerPosition: 'bottom-left',
    });
	$('.form_datetime').on('changeDate', function(ev){
    //if (ev.date.valueOf() < date-start-display.valueOf()){
	//console.log(ev);
	if(!checkTime(ev,this)) return false;
	
		var times =  $(this).children("input[type='text']").val();
		var form_date_div  = this ;
		var ajaxData = {};
		ajaxData["timeid"] = $(this).attr("id");
		ajaxData["time"] 	= times;
		ajaxData['__hash__'] = $('[name=__hash__]').attr('content');	
		//alert(ajaxData["timeid"]);
		$.ajax({
			cache:false,
			type:"POST",
			//async:false,
			//contentType:
			url:"{:U('HomeworkConf/setTime')}",
			dataType:"json",
			data: ajaxData,
			timeout:30000,
			error:function(XMLHttpRequest, textStatus,errorThrown){                      
				alert("设置失败，请检查网络或者重新设置！");
				$(form_date_div).children("input[type='text']").val("");
				$(form_date_div).next('input').val("");
				//t= this;
				//$("#dtp_input1_3").val("11");
				//$(form_date_div).children("span").click();
//t= this;				
				//alert(t);
				//console.log(t);
				return false;
			},
			success:function(jsApiParameters){
				if(jsApiParameters=='非法的请求方式' || typeof(jsApiParameters) == "undefined") {alert("网络问题，请稍后答题！");return false;}										
				alert('设置成功！');	
//alert(jsApiParameters['info']);				
			}
		});
    //}

    });
	
	$("span.add-on i.icon-remove").click(function (event){
		var icon_div = this;
		var ajaxData = {};
		ajaxData["timeid"] = $(this).parent('span').parent(".form_datetime").attr("id");;
		ajaxData["time"] 	= null;
		ajaxData['__hash__'] = $('[name=__hash__]').attr('content');	
		//alert(ajaxData["timeid"]);
		$.ajax({
			cache:false,
			type:"POST",
			//async:false,
			//contentType:
			url:"{:U('HomeworkConf/setTime')}",
			dataType:"json",
			data: ajaxData,
			timeout:30000,
			error:function(XMLHttpRequest, textStatus,errorThrown){                      
				alert("设置失败，请检查网络或者重新设置！");				
				return false;
			},
			success:function(jsApiParameters){
				if(jsApiParameters=='非法的请求方式' || typeof(jsApiParameters) == "undefined") {alert("网络问题，请稍后答题！");return false;}										
				$(icon_div).parent('span').prev("input[type='text']").val("");
				$(icon_div).parent('span').parent().next('input').val("");
				$(icon_div).parent('span').prev("input[type='text']").attr('placeholder','选择时间');
				alert('删除定时成功！');	
//alert(jsApiParameters['info']);				
			}
		});
	});
	
</script> 